package com.tsystems.tuni.sportplanet.dao;

import java.util.List;

import javax.persistence.Query;

import com.tsystems.tuni.sportplanet.entity.Season;
import com.tsystems.tuni.sportplanet.entity.Team;

/**
 * 
 * @author Yuriy Eremin
 * 
 */
public class SeasonDAOImpl extends GenericDAOImpl<Season> implements SeasonDAO {

	public SeasonDAOImpl() {
		super();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Season> getPlayedSeason(Team team) {
		String q = "select distinct r.game.season from Result r where r.team=:team";
		Query query = em.createQuery(q);
		query.setParameter("team", team);
		return query.getResultList();
	}

}
